load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")

go_library(
    name = "geoindex",
    srcs = [
        "geoindex.go",
        "s2_geography_index.go",
        "s2_geometry_index.go",
    ],
    importpath = "github.com/cockroachdb/cockroach/pkg/geo/geoindex",
    visibility = ["//visibility:public"],
    deps = [
        "//pkg/geo",
        "//pkg/geo/geogfn",
        "//pkg/geo/geographiclib",
        "//pkg/geo/geomfn",
        "//pkg/geo/geopb",
        "//pkg/geo/geoprojbase",
        "//pkg/geo/geos",
        "//pkg/sql/pgwire/pgcode",
        "//pkg/sql/pgwire/pgerror",
        "@com_github_cockroachdb_errors//:errors",
        "@com_github_golang_geo//r3",
        "@com_github_golang_geo//s1",
        "@com_github_golang_geo//s2",
        "@com_github_twpayne_go_geom//:go-geom",
    ],
)

go_test(
    name = "geoindex_test",
    size = "small",
    srcs = [
        "s2_geography_index_test.go",
        "s2_geometry_index_test.go",
        "utils_test.go",
    ],
    data = glob(["testdata/**"]) + ["//c-deps:libgeos"],
    embed = [":geoindex"],
    deps = [
        "//pkg/geo",
        "//pkg/geo/geogfn",
        "//pkg/geo/geopb",
        "//pkg/geo/geoprojbase",
        "//pkg/geo/geos",
        "//pkg/testutils/datapathutils",
        "//pkg/util/leaktest",
        "@com_github_cockroachdb_datadriven//:datadriven",
        "@com_github_golang_geo//s2",
        "@com_github_stretchr_testify//require",
    ],
)
